
package com.click.app.model;

import com.click.app.Functions;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author click
 */
@Entity
@Table(name = "asignation_request_laundry_pay")
public class AsignationRequestLaundryPay extends BaseObject{

    private static final long serialVersionUID = 1L;

    private Long id;
    private Double amountPayed;
    private LaundryRequest laundryRequest;
    private PaymentsLaundry paymentsLaundry;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_asignation_request_laundry_pay", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "amount_payed", precision = 6, scale = 0)
    public Double getAmountPayed() {
        return Functions.getDouble3Decimal(amountPayed);
    }

    public void setAmountPayed(Double amountPayed) {
        this.amountPayed = Functions.getDouble3Decimal(amountPayed);
    }

    @JoinColumn(name = "id_laundry_request", referencedColumnName = "id_laundry_request")
    @ManyToOne(optional = false)
    public LaundryRequest getLaundryRequest() {
        return laundryRequest;
    }

    public void setLaundryRequest(LaundryRequest laundryRequest) {
        this.laundryRequest = laundryRequest;
    }

    @JoinColumn(name = "id_payments_laundry", referencedColumnName = "id_payments_laundry")
    @ManyToOne(optional = false)
    public PaymentsLaundry getPaymentsLaundry() {
        return paymentsLaundry;
    }

    public void setPaymentsLaundry(PaymentsLaundry paymentsLaundry) {
        this.paymentsLaundry = paymentsLaundry;
    }

    @Override
    public String toString() {
        //return "com.click.app.model.AsignationCut[id=" + getId() + "]";
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                    .append(this.id).append(this.amountPayed).append(this.laundryRequest.getId())
                    .append(this.paymentsLaundry.getId()).toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final AsignationRequestLaundryPay other = (AsignationRequestLaundryPay) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.amountPayed != other.amountPayed && (this.amountPayed == null || !this.amountPayed.equals(other.amountPayed))) {
            return false;
        }
        if (this.laundryRequest != other.laundryRequest && (this.laundryRequest == null || !this.laundryRequest.equals(other.laundryRequest))) {
            return false;
        }
        if (this.paymentsLaundry != other.paymentsLaundry && (this.paymentsLaundry == null || !this.paymentsLaundry.equals(other.paymentsLaundry))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 89 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 89 * hash + (this.amountPayed != null ? this.amountPayed.hashCode() : 0);
        hash = 89 * hash + (this.laundryRequest != null ? this.laundryRequest.hashCode() : 0);
        hash = 89 * hash + (this.paymentsLaundry != null ? this.paymentsLaundry.hashCode() : 0);
        return hash;
    }

}
